/**
 * This class is used after receiving an activation message from the server
 * @author Steve
 */
package uicgas.register.remotecmds;

import uicgas.communication.RemoteCommand;
import uicgas.globaldata.ActivationData;
import uicgas.globaldata.MessagePayload;
import uicgas.register.Comunications;
import uicgas.register.RegisterLogic;
import uicgas.tools.UicGasGeneralException;

public class ActivatePump implements RemoteCommand
{
	private RegisterLogic register;
	
	/**
	 * General constructor for the RemoteCommand
	 * @author Steve
	 * @param register2
	 * @param comunications
	 */
	public ActivatePump(RegisterLogic register2, Comunications comunications)
	{
		this.register = register2;
	}
	
	/**
	 * general constructor for the RemoteCommand
	 * @author Steve
	 * @param register2
	 */
	public void executeRemoteCommand(RegisterLogic register2)
	{
		this.register = register2;
	}
	
	/**
	 * Executes a remote command in the register and checks to make sure we have a valid input type.
	 * @author Steve
	 * @throws UicGasGeneralException - Throws with the following message "Wrong data type received at ACTIVATE PUMP" 
	 * @return -1 - returned on null data condition
	 * @return 0 - returned on successful execution
	 * @param inData - the message data to be received, expected to be of type 'ActivationData' and is checked for validity.
	 */
	public int executeRemoteCommand(MessagePayload inData) throws UicGasGeneralException
	{
		//make sure we don't have missing data
		if(inData!=null)
		{
			//More Checking of information.
			//if(inData.getClass().getName().equals(ActivationData.class.getClass().getName()))
			//{
				//everything passed send the data on to the register system.
				register.ActivatePump(inData);
				return 0;
			//}
			//else
			//{
				//oops we have an issue, somehow we received the wrong data.
				//UicGasGeneralException myException = new UicGasGeneralException("Wrong data type received at ACTIVATE PUMP");
				//throw myException;
				//return -1;
			//}

		}
		else
		{	
			//returns -1 due to an null data condition.
			return -1;
		}
	}
	
	@Override
	/**
	 * General Execution case performs no actions.
	 * @author Steve
	 * @depricated
	 */
	public void executeRemoteCommand()
	{
	}
}
